package A;

public class Str {
    //一个字符串数组，计算两个没有相同元素的字符串长度乘积的最大值
    public static void main(String[] args) {


        String[] strings = {"abd","cdgfpz","ploj"};
        System.out.println(funC(strings));


    }
    public static int funC(String[] strings){
        int[] nums = new int[strings.length+1];
        for (int i = 1; i < strings.length; i++) {
            nums[i] = Math.max(nums[i-1],helper(strings,i));
        }
        int res = 0;
        for (int num:nums){
            res = Math.max(num,res);
        }
        return res;
    }

    private static int helper(String[] strings, int i) {
        int res = 0;
        String cur = strings[i];
        for (int j = 0; j < i; j++) {
            String s = strings[j];
            if(!isSame(cur,s)) {
                res = Math.max(res,s.length()*cur.length());
            }
        }
        return res;
    }

    private static boolean isSame(String cur, String s) {
        for (int i = 0; i < cur.length(); i++) {
            for (int j = 0; j < s.length(); j++) {
                if(cur.charAt(i)==s.charAt(j)){
                    return true;
                }
            }
        }
        return false;
    }
}

